package com.axend.aerosense.dev.fragment;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.axend.aerosense.base.fragment.MvvmBaseFragment;
import com.axend.aerosense.base.viewmodel.BaseViewModel;
import com.axend.aerosense.dev.R;
import com.axend.aerosense.dev.activity.NewDevSetNetActivity;
import com.axend.aerosense.dev.databinding.DevFragmentCalibrateResultBinding;

import org.jetbrains.annotations.NotNull;

public class DevCalibrateResultFragment extends MvvmBaseFragment<DevFragmentCalibrateResultBinding, BaseViewModel> {
    public static DevCalibrateResultFragment getInstance() {
        return new DevCalibrateResultFragment();
    }

    @Override
    public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView();
    }

    private void initView() {
        Bundle bundle = getArguments();
        boolean radarCalibrateResult = false;
        if (bundle != null) {
            radarCalibrateResult = bundle.getBoolean(DevBedCalibrationFragment.RADAR_CALIBRATE_RESULT, false);

        }
        if(getActivity()!=null){
            ((NewDevSetNetActivity)getActivity()).setFirstFragment(true);
        }else{
            ((NewDevSetNetActivity)requireActivity()).setFirstFragment(true);
        }

        if (radarCalibrateResult) {
            viewDataBinding.devImgRes.setImageResource(R.mipmap.dev_img_calibration_successful);
            viewDataBinding.devTvRes.setText(R.string.dev_bed_calibration_success_tips);
            viewDataBinding.devButRes.setText(R.string.common_sure);
        } else {
            viewDataBinding.devImgRes.setImageResource(R.mipmap.dev_img_calibration_failed);
            viewDataBinding.devTvRes.setText(R.string.dev_bed_calibration_fail_tips);
            viewDataBinding.devButRes.setText(R.string.common_next);
        }
        //but事件
        viewDataBinding.devButRes.setOnClickListener(v -> getActivity().onBackPressed());

    }




    @Override
    public int getLayoutId() {
        return R.layout.dev_fragment_calibrate_result;
    }

    @Override
    public int getBindingVariable() {
        return 0;
    }

    @Override
    protected BaseViewModel getViewModel() {
        return null;
    }

    @Override
    protected void onRetryBtnClick() {

    }
}
